﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NerdOnRails.DynamicProxy
{
	 public class DelegatedInvocationHandler : IInvocation
	 {
		  // Properties

		  #region BeforeMethodCallback
		  private Action<String, Type, Object[]> BeforeMethodCallback
		  {
				get;
				set;
		  }
		  #endregion

		  #region AfterMethodCallback
		  private Action<String, Type, Object> AfterMethodCallback
		  {
				get;
				set;
		  }
		  #endregion

		  // Constructors
		  public DelegatedInvocationHandler(Action<String, Type, Object[]> beforeMethodCallback, Action<String, Type, Object> afterMethodCallback)
		  {
				this.BeforeMethodCallback = beforeMethodCallback;
				this.AfterMethodCallback = afterMethodCallback;
		  }

		  // Methods
		  #region BeforeMethodInvocation
		  public void BeforeMethodInvocation(string methodName, Type invokedType, params object[] args)
		  {
				this.BeforeMethodCallback(methodName, invokedType, args);
		  }
		  #endregion

		  #region AfterMethodInvocation
		  public void AfterMethodInvocation(string methodName, Type invokedType, object result)
		  {
				this.AfterMethodCallback(methodName, invokedType, result);
		  }
		  #endregion

	 }
}
